import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from '@/config'

export async function login(data, publicKey) {
  // if (loginRSA) {
  //   data = await encryptedData(data)
  // }
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function getUserInfo(accessToken) {
  return request({
    url: '/user/getUserInfo',
    method: 'post',
  })
}

export function logout() {
  return request({
    url: '/user/loginOut',
    method: 'get',
  })
}

export function register() {
  return request({
    url: '/register',
    method: 'post',
  })
}

export function getPublicKey() {
  return request({
    url: '/auth/getPublicKey',
    method: 'get'
  })
}

export function getToken() {
  return localStorage.getItem('feilongshop-token')
}
